#include "SwitchNode.h"
#include "IRenderer.h"

HashedString SwitchNode::Type() const
{
	return HashedString("LightNode");
}

void SwitchNode::Enable()
{	
	if (m_switch)
	{
		for( Vector_t::reverse_iterator it = m_group1.rbegin(); it != m_group1.rend(); ++it )
			(*it)->Enable();
	} else
	{
		for( Vector_t::reverse_iterator it = m_group2.rbegin(); it != m_group2.rend(); ++it )
			(*it)->Enable();
	}
	Disable();
}

void SwitchNode::Disable()
{
}

void SwitchNode::Push_Back( Pointer<INode>& node )
{
	if (m_switch)
		m_group1.push_back( node );
	else
		m_group2.push_back( node );
	node->setParent(this);
}

void SwitchNode::Pop_Back( INode* node )
{
	for( Vector_t::iterator it = m_group1.begin(); it != m_group1.end(); ++it )
	{
		if( it->getPointer() == node )
		{
			m_children.erase( it );
			break;
		}
	}
	for( Vector_t::iterator it = m_group2.begin(); it != m_group2.end(); ++it )
	{
		if( it->getPointer() == node )
		{
			m_children.erase( it );
			break;
		}
	}
}